package edu.ccut.saturn.studio.database.popup.action;

import java.util.List;


import edu.ccut.saturn.studio.core.util.action.SaturnAction;
import edu.ccut.saturn.studio.core.util.eclipse.SaturnDialogUtil;
import edu.ccut.saturn.studio.database.model.DBConnection;
import edu.ccut.saturn.studio.database.model.SaturnTree;
import edu.ccut.saturn.studio.database.ui.DBConnectView;

/**
 * 关闭连接
 * 
 * @author 谷钰
 * @version 1.0 2008.12.06
 * 
 */
public class DisconnectAction extends SaturnAction {
	public void run() {
		try {
			List<SaturnTree> selecteds = DBConnectView.getInstance()
					.getCurrentSelections();

			if (selecteds != null) {
				for (SaturnTree selected : selecteds) {
					if (selected instanceof DBConnection) {
						DBConnectView.getInstance().removeDbConnection(
								(DBConnection) selected);
					}
				}
			}
		} catch (Exception e) {
			SaturnDialogUtil.openError(super.getShell(), e.getMessage());
		}
	}
}
